package main

import (
	"fmt"
	"github.com/micro/go-micro/v2"
	//"github.com/micro/go-plugins/registry/consul/v2"
	"gitee.com/Hu-Lyndon/distill-resk/infra/register/micro/handler"
	"gitee.com/Hu-Lyndon/distill-resk/infra/register/micro/proto"
	_ "github.com/micro/go-plugins/registry/consul/v2"
	"time"
)

func main() {

	//registry := consul.NewRegistry()
	//registry.Options()
	// 创建一个service
	service := micro.NewService(
		micro.Name("go.micro.service.user"),
		micro.RegisterTTL(time.Second*10),     // 5s检查等待时间
		micro.RegisterInterval(time.Second*5), //服务每5s发一次心跳

		//micro.Registry(registry),
	)

	service.Init()

	// 注册服务
	err := proto.RegisterUserServiceHandler(service.Server(), new(handler.User))
	if err != nil {
		fmt.Errorf("%+v", err)
	}

	// 启动服务
	if err := service.Run(); err != nil {
		fmt.Errorf("service Run Error:%+v", err)
	}
}
